﻿using System;
using System.ComponentModel;
using System.Xml.Serialization;
using Microsoft.WowAddonStudio.FrameXml.Serialization.TypeConverters;

namespace Microsoft.WowAddonStudio.FrameXml.Serialization
{
    /// <summary>
    /// Represents a ButtonStyle that can be used by <see cref="ButtonStyle"/>s and other FrameXML elements.
    /// </summary>
    [Serializable]
    [DesignerCategory("code")]
    [XmlType(Namespace = "http://www.blizzard.com/wow/ui/")]
    [XmlRoot(Namespace = "http://www.blizzard.com/wow/ui/", IsNullable = false)]
    [TypeConverter(typeof(ButtonStyleTypeConverter))]
    public class ButtonStyle : InheritableObject
    {
        /// <summary>
        /// Gets or sets the path to the ButtonStyle.
        /// </summary>
        [XmlAttribute("style")]
        public string Style
        {
            get { return Properties.GetValue<string>("Style"); }
            set { Properties.SetValue("Style", value); }
        }

        /// <summary>
        /// Gets a value indicating whether the buttonstyle is complete.
        /// </summary>
        [XmlIgnore]
        [Browsable(false)]
        public override bool IsComplete
        {
            get
            {
                return !String.IsNullOrEmpty(Style);
            }
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            if (!String.IsNullOrEmpty(Style))
                return Style;

            return "{ButtonStyle}";
        }
    }
}